<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\ArticleSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '文章列表';
$this->params['breadcrumbs'][] = $this->title;
//var_dump($dataProvider);die;
//var_dump($model);die;
?>
<div class="article-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('新增 文章', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'id',
            'user_id',
            'title',
            'content',
            'create_time:datetime',
            'views',
            'update_time:datetime',
            'release_time:datetime',
            'article_status',
            'sys_category_id',
            [
                'attribute' => 'sys_category_id',
                'value' =>function($model){
                    return $model->sysCategory->name;
                }
            ],
            ['class' => 'yii\grid\ActionColumn'],
    ],
    ]); ?>
</div>
